package m.jclecai.com.adapter;


import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.LinkedList;

import m.jclecai.com.inter.IAdapterChange;
import m.jclecai.com.inter.IAdapterItem;

public class BallsAdapter extends BaseAdapter {

    private LinkedList<IAdapterItem> mDatas = null;
    private IAdapterChange mChange = null;
    private String[] missDatas = null;
    private boolean mIsShowMissData = true;

    public BallsAdapter(IAdapterChange mChange) {
        super();
        this.mDatas = new LinkedList<IAdapterItem>();
        this.mChange = mChange;
        this.missDatas = new String[]{};
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return mDatas.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return mDatas.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return mDatas.get(arg0).getItemId();
    }

    @Override
    public View getView(int arg0, View arg1, ViewGroup arg2) {
        // TODO Auto-generated method stub
        return mChange.onItemChanged(arg0, arg1, arg2);
    }

    // 添加节点
    public void addItem(IAdapterItem item) {
        mDatas.add(item);
    }

    public void removeItem() {
        mDatas.clear();
    }

    public void addMissDataInfo(String s) {
        String[] split = TextUtils.isEmpty(s) ? new String[]{} : s.split(",");
        missDatas = split;
    }

    public String[] getMissDataInfo() {
        return missDatas;
    }

    public void showMissData() {
        mIsShowMissData = true;
        notifyDataSetChanged();
    }

    public boolean isShowMissData() {
        return mIsShowMissData;
    }

    public void setShowMissData(boolean showMissData) {
        mIsShowMissData = showMissData;
        notifyDataSetChanged();
    }

    public void hideMissData() {
        mIsShowMissData = false;
        notifyDataSetChanged();
    }
}
